<?php
namespace app\admin\controller;
use app\admin\controller\AdminController;
/**
 * 论坛设置
 */
class SettingController extends AdminController {

	/**
     * 设置页面
     */
    public function index(){
    	//设置目录导航
    	$this->adminCrumb[] = array('url'=>url('index'),'name'=>'论坛设置');
        //获取设置项目
        $this->assign('info',target('Config')->getInfo());
        $this->assign('upload',load_config(CONFIG_PATH.'upload.php'));
        $this->assign('performance',load_config(CONFIG_PATH.'performance.php'));
        $this->adminDisplay();
    }

    /**
     * 站点设置
     */
    public function infoSave(){
        if(!IS_POST){
            $this->error404();
        }
        if(target('Config')->saveData()){
            $this->success('站点配置成功！',url('index'));
        }else{
            $this->error('站点配置失败');
        }
    }

    /**
     * 上传设置
     */
    public function uploadSave(){
        if(!IS_POST){
            $this->error404();
        }
        $file = CONFIG_PATH . 'upload.php';
        if(save_config($file, $_POST)){
            $this->success('上传配置成功！',url('index'));
        }else{
            $this->error('上传配置失败');
        }
    }

    /**
     * 性能设置
     */
    public function performanceSave(){
        if(!IS_POST){
            $this->error404();
        }
        $file = CONFIG_PATH . 'performance.php';
        if(save_config($file, $_POST)){
            $this->success('性能配置成功！',url('index'));
        }else{
            $this->error('性能配置失败');
        }
    }
}

